package ace.module.sms.supplier.api.sms4j.core.impl;

import ace.cmp.i18n.api.MessageSourceAssertService;
import ace.cmp.json.api.JsonService;
import ace.module.sms.api.enums.SmsSupplierTypeEnum;
import ace.module.sms.supplier.api.SmsHandler;
import ace.module.sms.supplier.api.SmsHandlerFactory;
import ace.module.sms.supplier.api.dto.SupplierConfigDto;
import lombok.AllArgsConstructor;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author caspar
 * @date 2023/10/24 18:43 短信渠道提供者工厂
 */
@Order(1)
@AllArgsConstructor
@Component
public class Sms4JSmsHandlerFactoryImpl implements SmsHandlerFactory {
  private final JsonService jsonService;
  private final MessageSourceAssertService assertService;

  @Override
  public SmsHandler getOrCreate(SupplierConfigDto config) {
    return new Sms4JSmsHandler(config, jsonService, assertService);
  }

  @Override
  public boolean isSupport(String type) {
    return !SmsSupplierTypeEnum.TEST.getCode().equals(type);
  }
}
